package drds.server.sqlparser.sqlobject.statement.query.union_query;

import drds.server.sqlparser.sqlobject.statement.table.AbstractTable;
import drds.server.sqlparser.visitor.Visitor;

/**
 * 
 * @author 曹正辉<330937205@qq.com>
 * 
 */
public class UnionQueryTable extends AbstractTable {

	private UnionQuery unionQuery;

	public UnionQueryTable() {

	}

	public UnionQueryTable(UnionQuery unionQuery) {
		this.setUnionQuery(unionQuery);
	}

	public UnionQueryTable(UnionQuery unionQuery, String alias) {
		super(alias);
		this.setUnionQuery(unionQuery);
	}

	public void setUnionQuery(UnionQuery unionQuery) {
		if (unionQuery != null) {
			unionQuery.setParent(this);
		}
		this.unionQuery = unionQuery;
	}

	public UnionQuery getUnionQuery() {
		return unionQuery;
	}

	@Override
	protected void accept0(Visitor visitor) {
		if (visitor.visit(this)) {
			acceptChild(visitor, unionQuery);
		}
		visitor.endVisit(this);
	}

	public void output(StringBuffer sb) {
		sb.append("(");
		this.unionQuery.output(sb);
		sb.append(")");
	}

}
